import { get, post, put, del } from '@/utils/request';

/**
 * 权限相关API
 */

export interface GetPermissionsParams {
  page?: number;
  pageSize?: number;
  resource?: string;
  action?: string;
}

export const getPermissions = (params?: GetPermissionsParams) => {
  return get<any>('/permissions', params as any);
};

export const getPermissionById = (id: string) => {
  return get<any>(`/permissions/${id}`);
};

export const createPermission = (data: any) => {
  return post<any>('/permissions', data);
};

export const updatePermission = (data: any) => {
  const { id, ...rest } = data;
  return put<any>(`/permissions/${id}`, rest);
};

export const deletePermission = (id: string) => {
  return del(`/permissions/${id}`);
};

